﻿using MF.HSD.UpdateSalePriceListIspBP;
using System;
using System.Collections.Generic;
using System.Collections.Specialized;
using System.Linq;
using System.Text;
using System.Web.UI.WebControls.WebParts;
using UFSoft.UBF.UI.ControlModel;
using UFSoft.UBF.UI.Engine.Builder;
using UFSoft.UBF.UI.MD.Runtime.Common;
using UFSoft.UBF.UI.WebControlAdapter;

namespace MF_HSD_UIPlug.CostMonthBalanceMainUIFormWebPart
{

    public partial class HSDCostMonthBalanceMainUIFormWebPart : UFSoft.UBF.UI.Custom.ExtendedPartBase
    {

        public override void AfterInit(UFSoft.UBF.UI.IView.IPart part, EventArgs args)
        {
            this.Do_AfterInit(part, args); ;
        }

        #region 字段与属性                                       
        private UFIDA.U9.COST.CA.CostMonthBalanceUIModel.CostMonthBalanceMainUIFormWebPart _strongPart;
        #endregion
        private void Do_AfterInit(UFSoft.UBF.UI.IView.IPart part, EventArgs args)
        {
            #region 获取相关强类型数据                               

            _strongPart = part as UFIDA.U9.COST.CA.CostMonthBalanceUIModel.CostMonthBalanceMainUIFormWebPart;
            if (_strongPart == null)
                return;
            //初始化按钮
            IUFButton btnMergeInvoicePrint = new UFWebButtonAdapter();
            btnMergeInvoicePrint.Text = "更新内部结算价";
            btnMergeInvoicePrint.ID = "btnUpdatePrint";
            btnMergeInvoicePrint.AutoPostBack = true;
            IUFCard card = (IUFCard)_strongPart.GetUFControlByName(_strongPart.TopLevelContainer, "Card0");
            card.Controls.Add(btnMergeInvoicePrint);
            CommonFunction.Layout(card, btnMergeInvoicePrint, 8, 0);   //一般为从左往右按钮个数乘以2
            btnMergeInvoicePrint.Click += new EventHandler(btnCreateRcv_Click);
            #endregion
        }

        private void btnCreateRcv_Click(object sender, EventArgs e)
        {
            _strongPart.OnDataCollect(this);
            _strongPart.IsDataBinding = true; //当前事件执行后会进行数据绑定
            _strongPart.IsConsuming = false;

            UFSoft.UBF.Services.Session.ServiceSession.EnterOperator(this);
            UpdateSalePrice updateSale = new UpdateSalePrice();
            updateSale.Do();
            UFSoft.UBF.Services.Session.ServiceSession.ExitOperator(this);
        }
    }
}
